﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AutoComplete.ascx.cs" Inherits="Shop.Web.Controls.Ajax.AutoComplete" %>
<script language="javascript" type="text/javascript">
$().ready( function() {
	$("#<%= ac.ClientID %>").autocomplete(<%= LocalData ? JSDataName : "'" + DataUrl.ToString() + "'" %>, {
		delay: <%= Delay %>,
		width: <%= Width %>,
		matchContains: true,
		limit: <%= Limit > 0 ? Limit : Int32.MaxValue %>,
		max: <%= Max > 0 ? Max : Int32.MaxValue %>,
		formatItem: function(row) {
			<%= FormatItem %>;
		},
		formatResult: function(row) {
			<%= FormatResult %>;
		},
		selectFirst: <%= SelectFirst.ToString().ToLower() %>,
		minChars: <%= MinChars %>
	});
	$("#<%= ac.ClientID %>").result(function(event, data, formatted) {
		$("#<%= value.ClientID %>").val(typeof(data[1]) != 'undefined' ? data[1] : data.id);
		<%= String.IsNullOrEmpty(FindValueCallback) ? "" : FindValueCallback %>
	});
});
function <%= ClientID %>_Clear() {
	$("#<%= ac.ClientID %>").val("");
}
</script>
<asp:PlaceHolder ID="phLocalDataScript" Visible="false" runat="server">
<script language="javascript" type="text/javascript" src="<%= DataUrl.ToString() %>"></script>
</asp:PlaceHolder>
<input type="hidden" id="value" runat="server" />
<asp:TextBox ID="ac" CssClass="ac_input" runat="server" autocomplete="off"></asp:TextBox>
